home *** CD-ROM | disk | FTP | other *** search
- Path: argonet.co.uk!argbd86
- From: Charlotte Tomlinson <eeyore@argonet.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Urgent help - pointers to functions
- Date: Sat, 30 Mar 1996 11:57:33
- Organization: UnipalmPIPEX server (post doesn't reflect views of UnipalmPIPEX
- Distribution: world
- Message-ID: <internews46B6FAA4E6@argonet.co.uk>
- Reply-To: Charlotte Tomlinson <eeyore@argonet.co.uk>
- NNTP-Posting-Host: ao093.du.pipex.com
- X-Newsreader: VTi Voyager InterNews 0.15 for Acorn RISC OS (Patched by RA)
-
- I have implemented a template doubly linked list, the backbones of which
- is as follows:
-
- //dllist.h
-
- /*snip*/
-
- template <class T> class node
- {
- public:
- T data;
- node<T> *next;
- node<T> *prev;
- node();
- node(T info);
- node<T> *getnext() const {return next;}
- node<T> *getprev() const {return prev;}
- T getinfo() const {return data;}
- void change(T info) {data=info;}
- /*other functions*/
- };
-
- template <class T> class dllist : public node<T>
- {
- node<T> *start, *end;
- void copy(const dllist<T>);
-
- public:
- dllist() {start=end=NULL;}
- dllist(const dllist<T>&);
- int isEmpty() const;
- /*store, remove, find, ==, etc. snipped*/
- };
-
-
- Then I have a class, called fuzzyset, which uses this dll as a container
- for fuzzyel instances:
-
- //fuzzyset.h
- /*snip*/
-
- class fuzzyset {
- private:
- dllist<fuzzyel> members;
-
- public:
- fuzzyset() {}
- fuzzyset(const fuzzyset&);
- fuzzyset(const fuzzyel&);
- /*other functions and operators*/
- };
-
-
- What I would like to do is, within dllist, to implement a function forEach
- that take a pointer to a function as one argument, and somehow the rest of
- the arguments required by that function, and carries that function out
- over each element of the list.
-
- One example of what I need to do is as follows. In my main program (where
- fuzzyset is included), I need to be able to call a function that prints
- every element of the 'members' list in any called instance of a fuzzyset.
-
- I need the forEach function to be quite generic, because I will have other
- uses for it later.
-
- I hope someone can help. Many thanks in advance.
-
-
-
-
-
-
- ... *Configure Boot Big
- --
- -----------------------------------------------------------------------------
- | Charlotte Tomlinson | Mediocrity know nothing higher than itself, |
- | eeyore@argonet.co.uk | but talent instantly recognises genius. |
- |---------------------------------------------------------------------------|
- --------- Now WWWebbed up at http://www.argonet.co.uk/users/eeyore/ ---------
-
-